package com.xdxc.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xdxc.model.entity.ExamScoringTask;
import com.xdxc.model.entity.Exams;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface ExamsMapper extends BaseMapper<Exams> {
    @Select("SELECT e.* FROM exams e " +
            "LEFT JOIN exam_scoring_task est ON e.id = est.exam_id " +
            "WHERE e.end_time <= NOW() " +
            "AND e.status = 2 " +  // 考试状态为已结束
            "AND est.id IS NULL")   // 尚未创建评分任务
    List<Exams> selectFinishedExamsWithoutTask();
}
